package com.mbengue.corp.artisan.modele;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.Table;

@Entity
@Table(name="article")
@NamedNativeQueries(value = {
    @NamedNativeQuery(name = "toutesLesFeuillesD1Article", query = "select * from feuille f where f.numero in (select fa.numero from feuille_article fa where fa.code=?)", resultClass = Feuille.class),
    @NamedNativeQuery(name = "toutesLesFeuillesD1ArticleParType", query = "select * from feuille f where f.type=? and f.numero in (select fa.numero from feuille_article fa where fa.code=?)", resultClass = Feuille.class),
    @NamedNativeQuery(name = "trouverArticleParCode", query = "select * from article where code like ?", resultClass = Article.class) })
public class Article implements Serializable {
  private static final long serialVersionUID = 6000941678762251241L;

  @Id
  @Column(name = "code", length = 4)
	private String code;
  @Column(name = "designation", nullable = false, length = 100)
	private String designation;
  @Column(name = "prix", nullable = false)
	private double prix;
  @Column(name = "tva", nullable = false)
	private double tva;

	public Article() {
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getDesignation() {
		return designation;
	}

	public void setDesignation(String designation) {
		this.designation = designation;
	}

	public double getPrix() {
		return prix;
	}

	public void setPrix(double prix) {
		this.prix = prix;
	}

	public double getTva() {
		return tva;
	}

	public void setTva(double tva) {
		this.tva = tva;
	}

  @Override
  public String toString() {
    String artString = code + " " + designation + " " + prix + " " + tva;
    return artString;
  }

  public Object[] toArray() {
    Object[] table = { code, designation, prix, tva };
    return table;
  }
}
